GskRenderNode render_node;
PangoFont *font;
- guint has_color_glyphs : 1;
- guint hint_metrics : 1;
- guint antialias : 1;
- guint hint_style : 3;
+ gboolean has_color_glyphs;
GdkRGBA color;
graphene_point_t offset;
{
GskTextNode *self = (GskTextNode *) node;
PangoGlyphString glyphs;
- cairo_font_options_t *options;
glyphs.num_glyphs = self->num_glyphs;
glyphs.glyphs = self->glyphs;
cairo_save (cr);
- options = cairo_font_options_create ();
- cairo_font_options_set_hint_metrics (options, self->hint_metrics ? CAIRO_HINT_METRICS_ON : CAIRO_HINT_METRICS_OFF);
- cairo_font_options_set_antialias (options, self->antialias ? CAIRO_ANTIALIAS_GRAY : CAIRO_ANTIALIAS_NONE);
- cairo_font_options_set_hint_style (options, self->hint_style);
- cairo_set_font_options (cr, options);
- cairo_font_options_destroy (options);
-
gdk_cairo_set_source_rgba (cr, &self->color);
cairo_translate (cr, self->offset.x, self->offset.y);
pango_cairo_show_glyph_string (cr, self->font, &glyphs);
gsk_render_node_diff_impossible (node1, node2, region);
}
-static GskRenderNode *
-gsk_text_node_new_internal (const cairo_font_options_t *options,
- PangoFont *font,
- PangoGlyphString *glyphs,
- const GdkRGBA *color,
- const graphene_point_t *offset)
+/**
+ * gsk_text_node_new:
+ * @font: the `PangoFont` containing the glyphs
+ * @glyphs: the `PangoGlyphString` to render
+ * @color: the foreground color to render with
+ * @offset: offset of the baseline
+ *
+ * Creates a render node that renders the given glyphs.
+ *
+ * Note that @color may not be used if the font contains
+ * color glyphs.
+ *
+ * Returns: (nullable) (transfer full) (type GskTextNode): a new `GskRenderNode`
+ */
+GskRenderNode *
+gsk_text_node_new (PangoFont *font,
+ PangoGlyphString *glyphs,
+ const GdkRGBA *color,
+ const graphene_point_t *offset)
{
GskTextNode *self;
GskRenderNode *node;
self->color = *color;
self->offset = *offset;
self->has_color_glyphs = FALSE;
- self->antialias = TRUE;
- self->hint_style = CAIRO_HINT_STYLE_NONE;
- self->hint_metrics = FALSE;
-
- if (options)
- {
- self->antialias = cairo_font_options_get_antialias (options) != CAIRO_ANTIALIAS_NONE;
- self->hint_metrics = cairo_font_options_get_hint_metrics (options) == CAIRO_HINT_METRICS_ON;
- self->hint_style = cairo_font_options_get_hint_style (options);
- }
glyph_infos = g_malloc_n (glyphs->num_glyphs, sizeof (PangoGlyphInfo));
return node;
}
-/**
- * gsk_text_node_new_with_font_options:
- * @options: `cairo_font_options_t` to render with
- * @font: the `PangoFont` containing the glyphs
- * @glyphs: the `PangoGlyphString` to render
- * @color: the foreground color to render with
- * @offset: offset of the baseline
- *
- * Creates a render node that renders the given glyphs.
- *
- * Note that @color may not be used if the font contains
- * color glyphs.
- *
- * Returns: (nullable) (transfer full) (type GskTextNode): a new `GskRenderNode`
- *
- * Since: 4.6
- */
-GskRenderNode *
-gsk_text_node_new_with_font_options (const cairo_font_options_t *options,
- PangoFont *font,
- PangoGlyphString *glyphs,
- const GdkRGBA *color,
- const graphene_point_t *offset)
-{
- return gsk_text_node_new_internal (options, font, glyphs, color, offset);
-}
-
-/**
- * gsk_text_node_new:
- * @font: the `PangoFont` containing the glyphs
- * @glyphs: the `PangoGlyphString` to render
- * @color: the foreground color to render with
- * @offset: offset of the baseline
- *
- * Creates a render node that renders the given glyphs.
- *
- * Note that @color may not be used if the font contains
- * color glyphs.
- *
- * Returns: (nullable) (transfer full) (type GskTextNode): a new `GskRenderNode`
- */
-GskRenderNode *
-gsk_text_node_new (PangoFont *font,
- PangoGlyphString *glyphs,
- const GdkRGBA *color,
- const graphene_point_t *offset)
-{
- return gsk_text_node_new_internal (NULL, font, glyphs, color, offset);
-}
-
-/**
- * gsk_text_node_get_hint_metrics:
- * @node: (type GskTextNode): a text `GskRenderNode`
- *
- * Retrieves whether metrics hinting is enabled for rendering.
- *
- * See the cairo [documentation](https://www.cairographics.org/manual/cairo-cairo-font-options-t.html#cairo-hint-metrics-t).
- *
- * Returns: whether metrics hinting is enabled
- *
- * Since: 4.6
- */
-gboolean
-gsk_text_node_get_hint_metrics (const GskRenderNode *node)
-{
- const GskTextNode *self = (const GskTextNode *) node;
-
- return self->hint_metrics;
-}
-
-/**
- * gsk_text_node_get_antialias:
- * @node: (type GskTextNode): a text `GskRenderNode`
- *
- * Retrieves whether antialiasing is enabled for rendering.
- *
- * See the cairo [documentation](https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t).
- * Note that GSK only supports grayscale antialiasing.
- *
- * Returns: whether antialiasing is enabled
- *
- * Since: 4.6
- */
-gboolean
-gsk_text_node_get_antialias (const GskRenderNode *node)
-{
- const GskTextNode *self = (const GskTextNode *) node;
-
- return self->antialias;
-}
-
-/**
- * gsk_text_node_get_hint_style:
- * @node: (type GskTextNode): a text `GskRenderNode`
- *
- * Retrieves what style of font hinting is used for rendering.
- *
- * See the cairo [documentation](https://www.cairographics.org/manual/cairo-cairo-font-options-t.html#cairo-hint-style-t).
- *
- * Returns: what style of hinting is used
- *
- * Since: 4.6
- */
-cairo_hint_style_t
-gsk_text_node_get_hint_style (const GskRenderNode *node)
-{
- const GskTextNode *self = (const GskTextNode *) node;
-
- return self->hint_style;
-}
-
/**
* gsk_text_node_get_color:
* @node: (type GskTextNode): a text `GskRenderNode`